#include "Analysis.h"
BMS_AnalysisDataTypedef BMS_AnalysisData;
uint16_t SocOcvTab[101]=
{
	3282, // 0%~1%	
	3309, 3334, 3357, 3378, 3398, 3417, 3434, 3449, 3464, 3477,	// 0%~10%
	3489, 3500, 3510, 3520, 3528, 3536, 3543, 3549, 3555, 3561,	// 11%~20%
	3566, 3571, 3575, 3579, 3583, 3586, 3590, 3593, 3596, 3599,	// 21%~30%
	3602, 3605, 3608, 3611, 3615, 3618, 3621, 3624, 3628, 3632,	// 31%~40%
	3636, 3640, 3644, 3648, 3653, 3658, 3663, 3668, 3674, 3679,	// 41%~50%
	3685, 3691, 3698, 3704, 3711, 3718, 3725, 3733, 3741, 3748,	// 51%~60%
	3756, 3765, 3773, 3782, 3791, 3800, 3809, 3818, 3827, 3837,	// 61%~70%
	3847, 3857, 3867, 3877, 3887, 3897, 3908, 3919, 3929, 3940,	// 71%~80%
	3951, 3962, 3973, 3985, 3996, 4008, 4019, 4031, 4043, 4055,	// 81%~90%
	4067, 4080, 4092, 4105, 4118, 4131, 4145, 4158, 4172, 4185,	// 91~100%
};

void BMS_AnalysisDirect(void)
{
    uint8_t i;
    float volt;
    //最大电压差
    BMS_AnalysisData.MaxVoltDiffer=deal_data.Volt[4]-deal_data.Volt[0];
    
    //平均电压
    for(i=0;i<5;i++)
    {
    volt+=deal_data.Volt[i];
    }
    BMS_AnalysisData.AverageVoltage=volt/4;
    
    //实时功率
    BMS_AnalysisData.PowerReal=BQ_SampleData.BatteryVoltage*BQ_SampleData.BatteryCurrent;

    //最大和最小电压
    BMS_AnalysisData.CellVoltMax=deal_data.Volt[4];
    BMS_AnalysisData.CellVoltMin=deal_data.Volt[0];
}

//温度会影响电池容量，所以需要校准
static void BMS_AnalysisTemperCali(void)
{
    static int16_t lastTemp=0;
    uint8_t Ratio;//校准比率
    uint16_t RateTemp;
    int16_t MinTemp=deal_data.Volt[0];
}





